package com.area.cth.controller;

import com.area.cth.pojo.Message;
import com.area.cth.common.Result;
import com.area.cth.service.MessageService;
import com.area.cth.vo.MessageVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "消息相关接口")
@RestController
@RequestMapping("/message")
@CrossOrigin
public class MessageController {
    @Autowired
    private MessageService messageService;

    @Operation(summary = "根据对象id查询个人聊天记录")
    @GetMapping("/{id}")
    public Result<List<Message>> findAllMessageById(@PathVariable Integer id) {
        List<Message> ms=messageService.findAllMessageById(id);
        return Result.success(ms);
    }

    @Operation(summary = "查询个人消息列表")
    @GetMapping
    public Result<List<MessageVO>> findAllMessage() {
        List<MessageVO> mvs=messageService.findAllMessage();
        return Result.success(mvs);
    }
}
